<!DOCTYPE html>
<html>
<head>
    <meta charset=" utf-8">
    <title>宏任务与微任务</title>
</head>
<body>
    <button id="btn" onclick="test()">点击</button>
    <script>
        function test() {
            // window.location.href = "./test2.html";
        }

        let button = document.getElementById('btn');

        button.addEventListener('click', function CB1() {
            console.log('Listener 1');
            setTimeout(() => console.log('Timeout 1'))
            Promise.resolve().then(() => console.log('Promise 1'))
        });

        button.addEventListener('click', function CB1() {
            console.log('Listener 2');
            setTimeout(() => console.log('Timeout 2'))
            Promise.resolve().then(() => console.log('Promise 2'))
        });

    </script>
</body>

</html>